/**
 * Created by MadFrog on 2017/7/27.
 * 用于便捷生成常用的Ext组件
 */
var ExtComponentUtil = {};

// 列出管工系全体有效班级，多选
ExtComponentUtil.generateClassMultiComboBox = function () {
    var clazzStore = new Ext.data.JsonStore({
        url : "admin/clazz/listInSchoolClazz",
        totalProperty : "total",
        root : "rows",
//		autoLoad : true,
        fields : ["id", "name", "status", "enterSchoolDate", "graduateDate",
            "createDate", "updateDate", "des", "authorName", "owner"
        ]
    });
    var clazzCombo = new Ext.ux.form.LovCombo({
        store : clazzStore,
        fieldLabel : "班级",
        editable : false,
        resizable : true,
        width : 150,
        mode : "remote",
        displayField:"name",
        valueField: "id",
        triggerAction : "all",
        hiddenName : "clazzIds",
        autoSelect: true,
        showSelectAll: true,
        resizable: true
    });
    return clazzCombo;
}

ExtComponentUtil.generateClassComboBox = function () {
    var clazzStore = new Ext.data.JsonStore({
        url : "admin/clazz/listInSchoolClazz",
        totalProperty : "total",
        root : "rows",
//		autoLoad : true,
        fields : ["id", "name", "status", "enterSchoolDate", "graduateDate",
            "createDate", "updateDate", "des", "authorName", "owner"
        ]
    });
    var clazzCombo = new Ext.form.ComboBox({
        store : clazzStore,
        fieldLabel : "班级",
        editable : false,
        resizable : true,
        width : 150,
        mode : "remote",
        displayField:"name",
        valueField: "id",
        triggerAction : "all",
        hiddenName : "clazzId",
        multiSelect : true
    });
    return clazzCombo;
}

ExtComponentUtil.generateAttendStatusComboBox = function (){
    var AttendStatusStore = new Ext.data.ArrayStore({
        data : [["UNENROLL", "未报名"], ["UNSIGNIN", "未签到"], ["ATTEND", "正常参加"]],
        fields : ["attendStatus", "display"]
    });
    var AttendStatusCombo = new Ext.form.ComboBox({
        fieldLabel : "状态",
        store : AttendStatusStore,
        width : 70,
        editable : false,
        mode : "local",
        triggerAction : "all",
        valueField : "attendStatus",
        displayField : "display",
        hiddenName : "attendStatus",
        resizable : true,
        allowBlank : false
    });
    return AttendStatusCombo;
}

ExtComponentUtil.generateCourseComboByTeacher = function genCourseComboByTeacher(){
    var store = new Ext.data.JsonStore({
        url : "admin/course/listByTeacher",
        fields : ["id", "name"],
        root : "data",
        autoLoad : true
    });
    return new Ext.form.ComboBox({
        fieldLabel : "课程",
        store : store,
        editable : false,
        width : 70,
        mode : "remote",
        displayField:"name",
        valueField: "id",
        triggerAction : "all",
        hiddenName : "courseId"
    });
}


ExtComponentUtil.generateMentalCombo = function generateMentalCombo(){
    var store = new Ext.data.JsonStore({
        url : "admin/mental/list",
        fields : ["id", "name"],
        root : "data",
        autoLoad : true
    });
    return new Ext.form.ComboBox({
        fieldLabel : "心理测验类型",
        store : store,
        editable : false,
        mode : "remote",
        displayField:"name",
        valueField: "id",
        triggerAction : "all",
        hiddenName : "mentalId"
    });
}
